We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Model`s static findFirstById 'Model::findFIrstById()'

When I use 'Model::findFIrstById()' I want inseert sql in conditions, so what should I do.



85.5k
edited Feb '16

those are megic methods https://php.net/manual/en/language.oop5.overloading.php#object.get so you cant.

however ... simply do :


User::findFirst([
    "conditions" => " id = ?1 AND banned = ?2 ",
    "bind" => [
        1 => 65, //user id,
        2 => 0 // user banned value
    ]
);

you can see the source code of this functionality here : https://github.com/phalcon/cphalcon/blob/7cd81ef3c04f660f2d901aa285c051ec8f44c0a1/phalcon/mvc/model.zep#L4159



85.5k

you accept any answer here so thread can be solved, if you no longer need help of course